package com.sxbbc.common.core.service.impl;

import com.function.common.GetRest;
import com.function.common.RestResponse;
import com.sxbbc.common.core.entity.jz.AppVersion;
import com.sxbbc.common.core.mapper.jz.AppVersionMapper;
import com.sxbbc.common.core.service.IAppVersionService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

/**
 * <p>
 * app版本管理 服务实现类
 * </p>
 *
 * @author leehao
 * @since 2019-06-17
 */
@Service
public class AppVersionServiceImpl extends ServiceImpl<AppVersionMapper, AppVersion> implements IAppVersionService {

    /**
     * 保存版本信息
     * @param appVersion
     * @return
     */
    @Override
    public RestResponse editAliPayInfo(AppVersion appVersion) {
        if(appVersion.getId() == null){
            return GetRest.getFail("访问出错");
        }
        if(StringUtils.isBlank(appVersion.getAndroidUrl())){
            return GetRest.getFail("请输入安卓分发平台下载链接地址");
        }
        if(StringUtils.isBlank(appVersion.getAppId())){
            return GetRest.getFail("请输入IOS应用商店上的APPID");
        }
        if(appVersion.getIosVersion() == null){
            return GetRest.getFail("请输入IOS版本");
        }
        if(appVersion.getAppVersion() == null){
            return GetRest.getFail("请输入安卓版本");
        }
        boolean update = this.updateById(appVersion);
        if(!update){
            return GetRest.getFail("保存失败");
        }
        return GetRest.getSuccess("保存成功");
    }
}
